<template>
  <div>
    <div class="left">
      <el-menu
        :default-active="activeIndex"
        class="el-menu-vertical"
        @open="handleOpen"
        @close="handleClose"
        :router="true"
      >
        <el-menu-item index="/User/index">
          <i class="el-icon-menu"></i>
          <span slot="title">人员管理</span>
        </el-menu-item>
        <el-menu-item index="/User/Department">
          <i class="el-icon-document"></i>
          <span slot="title">部门管理</span>
        </el-menu-item>
        <el-menu-item index="/User/Role">
          <i class="el-icon-setting"></i>
          <span slot="title">角色权限配置</span>
        </el-menu-item>
      </el-menu>
    </div>
    <div class="right">
      <router-view></router-view>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeIndex: this.$route.path
    }
  },
  methods: {
    handleOpen(key, keyPath) {
      console.log(key, keyPath)
    },
    handleClose(key, keyPath) {
      console.log(key, keyPath)
    }
  },
  beforeMounted() {
    console.log(this.$route.path)
    this.activeIndex = this.$route.path
  }
}
</script>

<style lang="stylus">
.left
  float left
  width 15%
  height calc(100vh - 60px)
.right
  float left
  width 85%
  height 100%
.el-menu-vertical
  height 100%
</style>
